#ifndef GOBANVIEW_HPP
#define GOBANVIEW_HPP

#include <QGraphicsScene>
#include <QGraphicsView>
#include <QPixmap>
#include <QDebug>
#include "goban.hpp"
#include <QGraphicsPixmapItem>
#include <QMouseEvent>
#include "client.hpp"
#include "gamewindow.hpp"

class Client;
class GameWindow;
class Goban;

class GobanView : public QGraphicsView
{
    Q_OBJECT
public:
    GobanView(Client * client, GameWindow * gameWindow, int size, Goban * goban);
    ~GobanView();
    void mousePressEvent(QMouseEvent *event);
    void addKO(QPair<int, int> ko);
    void removeKO(QPair<int, int> ko);

private:
    QGraphicsScene * _scene;
    QPixmap * _background;
    QPixmap * _blackStone;
    QPixmap * _whiteStone;
    QPixmap * _ko;
    QPixmap * _blackDead;
    QPixmap * _whiteDead;
    QPixmap * _blackTerritory;
    QPixmap * _whiteTerritory;
    QPixmap * _blackTerritoryWhiteDead;
    QPixmap * _whiteTerritoryBlackDead;

    GameWindow * _gameWindow;
    Client * _client;
    Goban * _goban;

    int _offset;
    int _squareSide;
    int _size;
    int _stoneSize;

    QHash <QPair<int, int>, QGraphicsPixmapItem *> _itemVector;

public slots:
    void addStone(int x, int y, bool color);
    void addStone(int x, int y, quint8 color);
    void deleteGroup(const QVector <QPair<int, int> > & group);
};

#endif // GOBANVIEW_HPP
